// pages/index/index.js
import request from '../../utils/request'
const app = getApp()
Page({
  data: {
    value: '',
    userInfo: null,
    competitionList: []
  },

  showDetail(e) {
    const { detail } = e.currentTarget.dataset
    wx.navigateTo({
      url: '../detail/competition/index',
      success(result) {
        result.eventChannel.emit('deliverCompetitionDetail', { detail })
      }
    })
  },

  fetchInputValue (e) {
    this.setData({
      value: e.detail.value
    })
  },

  goMyPage() {
    wx.switchTab({
      url: '/pages/individual/index',
    })
  },

  onLoad() {
    
  },

  onShow() {
    this.setData({ userInfo: app.globalData.userInfo })
    request.get('/competition/all').then(result => {
      this.setData({ competitionList: result.data })
    })
    if (typeof this.getTabBar === 'function' &&
      this.getTabBar()) {
      this.getTabBar().setData({
        current: 'index'
      })
    }
  },
})
